D2D communication is a technology that directly performs data exchange or a service without forwarding by using a network. For example, a Bluetooth module of a terminal may be always enabled for scanning, or when a transmission distance supported by Bluetooth is satisfied, a user manually enables a Bluetooth module at a local end, to establish a connection with scanned peer-end Bluetooth. The user may select data to be transmitted by using Bluetooth, and data transmission may be performed by using Bluetooth between the local end and the peer end. In this way, a process of D2D discovery and data transmission is completed.
An LTE (Long Term Evolution) cellular network may include user equipment A (UE A,), user equipment B (UE B), a ProSe A server to which the UEA belongs, a ProSe Server B to which the UEB belongs, a GMLC (Gateway Mobile Location Center) A to which the UEA belongs, and a GMLC B to which the UEB belongs. In the prior art, steps of establishing D2D communication in the LTE cellular network may include: (1) The UE A registers with the ProSe server A to which the UEA belongs, and the ProSe server A obtains a ProSe identifier A and an application identifier A of the UE A; the UE B registers with the ProSe server B to which the UE B belongs, and the ProSe server B obtains a ProSe identifier B and an application identifier B of the UE B. (2) The GMLC A updates location information of the UE A, the GMLC B updates location information of the UE B, the ProSe server A may obtain the location information of the UEA from the GMLC A, the ProSe server B may obtain the location information of the UEB from the GMLC B, the ProSe server A may obtain the location information of the UE B from the ProSe server B, and the ProSe server B may obtain the location information of the UE A from the ProSe server A. (3) The UE A requests to the ProSe server A for a D2D pairing with the UEB. For example, the ProSe server A may calculate a distance D between the UE A and the UEB according to the location information of the UE A and the location information of the UE B, and determine whether the distance D meets a pairing distance S; and if the distance D meets the pairing distance S, notify the UE A that the UE A can perform D2D communication with the UEB. In the prior art, the following problems exist in establishing D2D communication in the LTE cellular network: A third-party server needs to be deployed, and for different operators, message interfaces for different ProSe servers further need to be deployed, which increases a deployment difficulty. In addition, a network element, such as a core network, an access network, or user equipment, needs to support positioning, and network signaling overheads are high, which increases burden of the cellular network. Moreover, there lacks diversified positioning manners. Currently, a manner having relatively high positioning precision, that is, OTDOA (Observed Time Difference of Arrival), may be used in the LTE cellular network, but the positioning precision is far lower than a positioning manner such as GPS (Global Positioning System).